package www.dianbaozu.com.ui.chat.findFriend.adapter

import androidx.recyclerview.widget.RecyclerView
import com.netease.nim.uikit.R
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseSectionQuickAdapter
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder
import com.netease.nimlib.sdk.friend.model.Friend
import com.netease.nimlib.sdk.search.model.MsgIndexRecord
import www.dianbaozu.com.ui.chat.findFriend.holder.FindFriendRecentContactViewHolder
import www.dianbaozu.com.ui.chat.findFriend.holder.FindFriendViewHolder
import www.dianbaozu.com.ui.chat.findFriend.holder.HeaderViewHolder

class FindFriendsAdapter(recyclerView: RecyclerView, data: List<Any>) :
    BaseMultiItemQuickAdapter<Any, BaseViewHolder>(recyclerView, data) {

    companion object {
        const val VIEW_TYPE_FRIEND = 1
        const val VIEW_TYPE_RECENT_CONTACT = 2
        const val VIEW_TYPE_HEADER = 3
    }

    init {
        addItemType(VIEW_TYPE_FRIEND, R.layout.item_friends, FindFriendViewHolder::class.java)
        addItemType(
            VIEW_TYPE_RECENT_CONTACT,
            R.layout.item_friends,
            FindFriendRecentContactViewHolder::class.java
        )
        addItemType(VIEW_TYPE_HEADER, R.layout.item_header, HeaderViewHolder::class.java)
    }

    override fun getViewType(item: Any): Int {
        if (item is MsgIndexRecord) {
            return VIEW_TYPE_RECENT_CONTACT
        } else if (item is Friend) {
            return VIEW_TYPE_FRIEND
        } else {
            return VIEW_TYPE_HEADER
        }
    }

    override fun getItemKey(item: Any?): String =
        item.toString()
}